import os
import torch
import numpy as np
import random

def triu(x, diagonal=0):
    return torch.tril(x, diagonal)

def gen_golden_data_simple():
    # Fixed shape as in your original code
    shape = [15, 77, 2133]
    
    # Random diagonal between -min_dim and max_dim
    min_dim = min(77, 2133)  # smallest of last two dimensions
    diagonal = random.randint(0, min_dim)
    
    input_x = np.random.uniform(-10, 10, shape).astype(np.float16)
    golden = triu(torch.Tensor(input_x), diagonal=diagonal).numpy().astype(np.float16)

    tiling = np.array([shape[0], shape[1], shape[2], diagonal], dtype=np.uint32)
    print("goledn",golden)
    
    os.system("mkdir -p input")
    os.system("mkdir -p output")
    

    input_x.tofile("./input/input_x.bin")
    tiling.tofile("./input/input_tiling.bin")
    golden.tofile("./output/golden.bin")

if __name__ == "__main__":
    gen_golden_data_simple()